<?php
class ImageAlbumModel extends Model
{
    private $db;
    function  __construct()
    {
        $this->db = DataProvider::getInstance();
        parent::__construct();
    }

    public function getAlbumList()
    {
        $albums = $this->db->get('album', array('status'=>'1'))->getAll();
        foreach ($albums as &$album)
        {
            $rs = $this->db->get('item',array('album_id'=>$album->id), null, 1, 0);
            if (count($rs->getAll()) == 1)
                $album->thumbnail = $rs->getRow(0)->thumbnail;
        }
        return $albums;
    }
}